<template>
  <ul>
    <template v-for="item in routeList">

      <router-link :key="item.text" :to="item.routeTo" tag="li" :replace="replace" :exact="item.exact" v-if="tag ==='li'">
        <a>
                      {{item.text}}
                    </a>
      </router-link>
      <li v-else :key="item.path">
        <router-link :to="item.routeTo" :replace="replace" :exact="item.exact">{{item.text}}</router-link>
      </li>
    </template>
  </ul>

</template>

<script>
// import StatisticsTable from './nav2statistics'
export default {
  name: 'navList',
  props: {
    routeListData: {
      required: true
    },
    tag: {
      type: String,
      default: 'li'
    },
    replace: {
      type: Boolean,
      default: false
    },
    query: {
      type: Object,
      default: null
    }

  },
  data () {
    return {

    }
  },
  components: {
  },
  methods () {

  },
  computed: {
    routeList () {
      let routeList = []
      let vm = this
      let routeListData = vm.routeListData
      // 构造导航栏路径参数
      // 数据结构：
      // '检测数据'：{
      //   path: 'test-data',
      //   query: {
      //     uid: 23444
      //   }
      // }
      for (let key in routeListData) {
        let route = routeListData[key]
        routeList.push({
          text: route.text,
          routeTo: {
            path: key,
            query: route.query ? route.query : this.query,
            params: route.params
          },
          exact: route.exact
        })
      }
      return routeList
    }
  }
}
</script>
